struct ListNode* Merge(struct ListNode* pHead1, struct ListNode* pHead2) {
    // write code here
    struct ListNode* phead = (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode* p = phead;
    while (pHead1 && pHead2) {
        if (pHead1->val <= pHead2->val) {
            p->next = pHead1;
            pHead1 = pHead1->next;
        }
        else {
            p->next = pHead2;
            pHead2 = pHead2->next;
        }
        p = p->next;
    }
    p->next = pHead1 ? pHead1 : pHead2;
    return phead->next;
}